package expr;
import util.bio.parsers.*;
import java.util.*;

/**Container for holding alleles affecting a particular gene model.*/
public class AffectedGene {
	
	//fields
	private UCSCGeneLine geneModel;
	private Allele[] alleles;
	private String[] effects;
	
	//constructor
	public AffectedGene (UCSCGeneLine geneModel, Allele[] alleles, String chromSeq){
		this.geneModel = geneModel;
		this.alleles = alleles;
		mutate(chromSeq);
	}

	//methods
	/**Characterizes effects of each allele on the gene model.*/
	public void mutate(String chromSeq){
		effects = new String[alleles.length];
		for (int i=0; i< alleles.length; i++){
			effects[i] = alleles[i].affect(geneModel, chromSeq);
		}
	}
	
	public String toString(){
		StringBuilder sb = new StringBuilder();
		sb.append(geneModel.simpleToString());
		sb.append("\n");
		//warn if no cds
		if (geneModel.getCdsEnd() == geneModel.getCdsStart()) {
			sb.append("\n\tWARNING: No coding sequence indicated!\n\n");
		}
		for (int i=0; i< alleles.length; i++){
			sb.append("\t");
			sb.append(alleles[i]);
			sb.append("\n");
			sb.append(effects[i]);
		}
		
		
		return sb.toString();
	}
	
	//getters and setters
	public UCSCGeneLine getGeneModel() {
		return geneModel;
	}
	public Allele[] getAlleles() {
		return alleles;
	}
	
	
}
